﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Sustainalytics.ScreeningTool.Service.Tests
{
    [TestClass()]
    public class TemplateCriteriaControllerTests
    {
        //[TestMethod]
        //public void Get()
        //{
        //    Guid companyInfoCriteriaLevel1Id = Guid.NewGuid();
        //    Guid esgCompositeCriteriaLevel1Id = Guid.NewGuid();
        //    Guid businessOverviewCriteriaLevel2Id = Guid.NewGuid();
        //    Guid generalCriteriaLevel2Id = Guid.NewGuid();
        //    Guid esgEventsCriteriaLevel2Id = Guid.NewGuid();
        //    Guid baseCriteriaId1 = Guid.NewGuid();
        //    Guid baseCriteriaId2 = Guid.NewGuid();
        //    Guid baseCriteriaId3 = Guid.NewGuid();
        //    Guid baseCriteriaId4 = Guid.NewGuid();
        //    Guid baseCriteriaId5 = Guid.NewGuid();
        //    List<BaseCriteria> baseCriteriaList = new List<BaseCriteria>();
        //    baseCriteriaList.Add(new BaseCriteria() { Id = baseCriteriaId1, Name = "Market capitalization", CriteriaEntity = "FinancialData", CriteriaEntityField = "MarketCapitalization", CriteriaLevel2Id = businessOverviewCriteriaLevel2Id, CriteriaType = CriteriaTypeEnum.CriteriaType1 });
        //    baseCriteriaList.Add(new BaseCriteria() { Id = baseCriteriaId2, Name = "Number of employees", CriteriaEntity = "CompanyInfo", CriteriaEntityField = "NumberOfEmployees", CriteriaLevel2Id = generalCriteriaLevel2Id, CriteriaType = CriteriaTypeEnum.CriteriaType1 });
        //    baseCriteriaList.Add(new BaseCriteria() { Id = baseCriteriaId3, Name = "Basic labour standards", CriteriaEntity = "EventIndicator", CriteriaEntityField = "BaseEventIndicatorId", CriteriaLevel2Id = esgEventsCriteriaLevel2Id, CriteriaType = CriteriaTypeEnum.CriteriaType2 });
        //    baseCriteriaList.Add(new BaseCriteria() { Id = baseCriteriaId4, Name = "Business Ethics", CriteriaEntity = "EventIndicator", CriteriaEntityField = "BaseEventIndicatorId", CriteriaLevel2Id = esgEventsCriteriaLevel2Id, CriteriaType = CriteriaTypeEnum.CriteriaType2 });
        //    baseCriteriaList.Add(new BaseCriteria() { Id = baseCriteriaId5, Name = "Child Labour", CriteriaEntity = "EventIndicator", CriteriaEntityField = "BaseEventIndicatorId", CriteriaLevel2Id = esgEventsCriteriaLevel2Id, CriteriaType = CriteriaTypeEnum.CriteriaType2 });

        //    var companyScreeningService = new Sustainalytics.ScreeningTool.BL.Fakes.StubICompanyScreening()
        //    {
        //        GetBaseCriteriaGuid = (id) =>
        //        {
        //            return baseCriteriaList.Where(bc => bc.Id == id).SingleOrDefault();
        //        },
        //        ListBaseCriteriaNullableOfGuid = (criteriaLevel2Id) =>
        //        {
        //            if (criteriaLevel2Id.HasValue)
        //                return baseCriteriaList.Where(bc => bc.CriteriaLevel2Id == criteriaLevel2Id).ToList();

        //            return baseCriteriaList;
        //        },
        //        LoadCriteriaTypeOneGuid = (id) =>
        //            {
        //                var baseCriteria = baseCriteriaList.Where(i => i.Id == id).SingleOrDefault();
        //                CriteriaTypeOne cr1 = new CriteriaTypeOne()
        //                {
        //                    Id = baseCriteria.Id,
        //                    CriteriaEntity = baseCriteria.CriteriaEntity,
        //                    CriteriaEntityField = baseCriteria.CriteriaEntityField,
        //                    Name = baseCriteria.Name,
        //                    CriteriaType = baseCriteria.CriteriaType,
        //                    Order = baseCriteria.Order
        //                };

        //                return cr1;
        //            },
        //        LoadCriteriaTypeTwoGuid = (id) =>
        //            {
        //                var baseCriteria = baseCriteriaList.Where(i => i.Id == id).SingleOrDefault();
        //                CriteriaTypeTwo cr2 = new CriteriaTypeTwo()
        //                {
        //                    Id = baseCriteria.Id,
        //                    CriteriaEntity = baseCriteria.CriteriaEntity,
        //                    CriteriaEntityField = baseCriteria.CriteriaEntityField,
        //                    Name = baseCriteria.Name,
        //                    CriteriaType = baseCriteria.CriteriaType,
        //                    Order = baseCriteria.Order
        //                };

        //                return cr2;
        //            },
        //        LoadCriteriaTypeThreeGuid = (id) =>
        //            {
        //                var baseCriteria = baseCriteriaList.Where(i => i.Id == id).SingleOrDefault();
        //                CriteriaTypeThree cr3 = new CriteriaTypeThree()
        //                {
        //                    Id = baseCriteria.Id,
        //                    CriteriaEntity = baseCriteria.CriteriaEntity,
        //                    CriteriaEntityField = baseCriteria.CriteriaEntityField,
        //                    Name = baseCriteria.Name,
        //                    CriteriaType = baseCriteria.CriteriaType,
        //                    Order = baseCriteria.Order
        //                };

        //                return cr3;
        //            },
        //        LoadCriteriaTypeFiveGuid = (id) =>
        //            {
        //                var baseCriteria = baseCriteriaList.Where(i => i.Id == id).SingleOrDefault();
        //                CriteriaTypeFive cr5 = new CriteriaTypeFive()
        //                {
        //                    Id = baseCriteria.Id,
        //                    CriteriaEntity = baseCriteria.CriteriaEntity,
        //                    CriteriaEntityField = baseCriteria.CriteriaEntityField,
        //                    Name = baseCriteria.Name,
        //                    CriteriaType = baseCriteria.CriteriaType,
        //                    Order = baseCriteria.Order
        //                };

        //                return cr5;
        //            },
        //        LoadCriteriaTypeSixGuid = (id) =>
        //            {
        //                var baseCriteria = baseCriteriaList.Where(i => i.Id == id).SingleOrDefault();
        //                CriteriaTypeSix cr6 = new CriteriaTypeSix()
        //                {
        //                    Id = baseCriteria.Id,
        //                    CriteriaEntity = baseCriteria.CriteriaEntity,
        //                    CriteriaEntityField = baseCriteria.CriteriaEntityField,
        //                    Name = baseCriteria.Name,
        //                    CriteriaType = baseCriteria.CriteriaType,
        //                    Order = baseCriteria.Order
        //                };

        //                return cr6;
        //            },
        //        LoadCriteriaTypeOneDataGuidListOfInt32 = (id, universeIds) =>
        //            {
        //                return new List<CriteriaChartData>();
        //            },
        //        LoadCriteriaTypeSixDataGuidListOfInt32 = (id, universeIds) =>
        //            {
        //                return new List<CriteriaChartData>();
        //            },
        //        LoadCriteriaTypeThreeDataGuidListOfInt32Int32Int32StringInt32Out = (Guid id, List<int> universeIds, int skip, int take, string searchText, out int totalCount) =>
        //            {
        //                totalCount = 0;
        //                return new List<string>();
        //            }
        //    };

        //    var templateCriteriaController = Utils.setupController<TemplateCriteriaController>(new TemplateCriteriaController(companyScreeningService));

        //    TemplateCriteriaOptions options = new TemplateCriteriaOptions();
        //    List<object> templateCriteriaList = new List<object>();
        //    HttpResponseMessage templateCriteria = templateCriteriaController.Get(companyInfoCriteriaLevel1Id, esgEventsCriteriaLevel2Id, options);

        //    Assert.IsNotNull(templateCriteria, "The criteria tabs should not be null.");
        //    Assert.IsTrue(templateCriteria.IsSuccessStatusCode, "The request has failed.");
        //    Assert.IsTrue(templateCriteria.TryGetContentValue<List<object>>(out templateCriteriaList), "The response does not contain the list of template criteria dto.");
        //    Assert.AreEqual(baseCriteriaList.Count(i => i.CriteriaLevel2Id == esgEventsCriteriaLevel2Id), templateCriteriaList.Count, "The number of template criteria is different than the expected one.");

        //    object templateCriteriaDto = null;
        //    templateCriteria = templateCriteriaController.Get(baseCriteriaId2, options, 2);

        //    Assert.IsNotNull(templateCriteria, "The criteria tabs should not be null.");
        //    Assert.IsTrue(templateCriteria.IsSuccessStatusCode, "The request has failed.");
        //    Assert.IsTrue(templateCriteria.TryGetContentValue<object>(out templateCriteriaDto), "The response does not contain the list of template criteria dto.");
        //}
    }
}
